<template>
  <div class="page-container" v-loading="pageLoading">
    <el-card>
      <template #header>
        <div class="card-header">
          <span>{{route.query?.id}}项目状态</span>
        </div>
      </template>
      <el-steps :active="activeStep" align-center>
        <el-step v-for="step in steps" :title="step.label" :key="step.value" />
      </el-steps>
    </el-card>

    <el-card style="margin-top: 10px;">
      <template #header>
        <div class="card-header">
          <span>项目详情</span>
        </div>
      </template>
      <el-descriptions>
        <el-descriptions-item label="企业名称：">{{merTask?.merchantName}}</el-descriptions-item>
        <el-descriptions-item label="企业编号：">{{merTask.merNo}}</el-descriptions-item>
        <el-descriptions-item label="服务商名称：">{{merTask.gsmc}}</el-descriptions-item>
        <el-descriptions-item label="服务商编号：">{{merTask.id}}</el-descriptions-item>
        <el-descriptions-item label="项目名称：">{{merTask.name}}</el-descriptions-item>
        <el-descriptions-item label="项目金额：">{{merTask.cost}} ~ {{merTask.costMax}}</el-descriptions-item>
        <el-descriptions-item label="项目人数：">{{merTask.limitNum}}</el-descriptions-item>
        <el-descriptions-item label="所属行业：">{{merTask.industryName}}</el-descriptions-item>
        <el-descriptions-item label="所属子行业：">{{merTask.twoIndustryName}}</el-descriptions-item>
        <el-descriptions-item label="项目内容：">{{merTask.proContent}}</el-descriptions-item>
      </el-descriptions>
    </el-card>
    <el-card style="margin-top: 10px;">
      <template #header>
        <div class="card-header">
          <span>操作日志</span>
        </div>
      </template>
      <el-table :data="logRecords">
        <el-table-column prop="createTime" label="日志时间"></el-table-column>
        <el-table-column prop="logDesc" label="日志内容"></el-table-column>
        <el-table-column prop="createRoleId" label="操作角色"></el-table-column>
      </el-table>
    </el-card>
    <div class="footer">
      <el-button @click="$router.back()">返回</el-button>
    </div>
  </div>
</template>

<script lang="ts" setup>
import type { TaskInfo } from '../types'
const route = useRoute();

const MapTaskStatus = {
  0: 0,
  1: 1,
  2: 2,
  3: 2,
  4: 3,
  5: 3,
  6: 4,
  7: 5,
  8: 6,
}

const pageLoading = ref(true)
const { proxy } = getCurrentInstance() as ComponentInternalInstance
/**
 * TODO
 * 查询角色信息字典
 * 回显label
 * 角色信息字典名称未知
*/
const list = toRefs<any>(proxy?.useDict("sys_role"));

/**
 * 项目状态
*/
const steps = computed(() => {
  const list = proxy?.useDict("task_status").task_status
  return list
})



const { data } = useRequest(`/payment/task/${route.query.id}`, 'GET', {}, { immediate: true })

const merTask = computed<TaskInfo>(() => {
  return data?.value?.merTask || {}
})

const logRecords = computed(() => {
  return data?.value?.logRecords || []
})


const activeStep = computed(() => {
  return  MapTaskStatus[merTask.value?.taskStatus]  || -1
})


onMounted(() => {
  setTimeout(() => {
      pageLoading.value = false
  }, 500);
})
</script>

<style scoped lang="scss">
.page-container {
  padding: 5px 15px 5px 10px;
  height: calc(100vh - 89px);
  overflow-y: auto;

  .footer {
    background: #fff;
    text-align: center;
    z-index: 999;
    margin-top: 20px;
  }
}
</style>
